package com.shanzmoo.db.sys.entity.dto;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.db.sys.entity.RoleEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 角色保存对象
 * @author Gzhao
 * @date 2020/11/16
 */
@Data
@ApiModel("角色保存对象")
public class RoleSaveDto {

    @NotBlank(message = "角色名不允许为空")
    @ApiModelProperty("角色名" )
    private String roleName;

    @NotBlank(message = "权限字符不允许为空")
    @ApiModelProperty("权限字符" )
    private String roleKey;

    @NotNull(message = "状态不允许为空")
    @ApiModelProperty("状态：1-启用，2-禁用" )
    private Boolean status;

    @ApiModelProperty("描述" )
    private String description;

    @ApiModelProperty("菜单权限id列表" )
    private List<Integer> menuIds;

    public static RoleEntity converted(RoleSaveDto saveDto) {
        return JSON.parseObject(JSON.toJSONString(saveDto), RoleEntity.class);
    }
}
